#! /bin/bash

OUT_DIR="../_out/cmd"
CMD_DIR="../cmd"
DOCKER_REPO=$1

BASE_DIR=$(pwd)

DOCKER_BASE_DIR=${BASE_DIR}/dockerbuild

# echo "cd ${BASE_DIR}"
# echo "cp ${OUT_DIR}/virt-api/virt-api ${DOCKER_BASE_DIR}/virt-api/"

# Virt-Api
cd ${BASE_DIR}
cp ${OUT_DIR}/virt-api/virt-api ${DOCKER_BASE_DIR}/virt-api/
cd ${DOCKER_BASE_DIR}/virt-api/
docker build -t ${DOCKER_REPO}/kubevirt/virt-api:0.48.1-1040 .

# Virt-Operator
cd ${BASE_DIR}
cp ${OUT_DIR}/virt-operator/virt-operator ${DOCKER_BASE_DIR}/virt-operator/
cp ${OUT_DIR}/tools/csv-generator/csv-generator ${DOCKER_BASE_DIR}/virt-operator/
cd ${DOCKER_BASE_DIR}/virt-operator/
docker build -t ${DOCKER_REPO}/kubevirt/virt-operator:0.48.1-1040 .

# Virt-Controller
cd ${BASE_DIR}
cp ${OUT_DIR}/virt-controller/virt-controller ${DOCKER_BASE_DIR}/virt-controller/
cd ${DOCKER_BASE_DIR}/virt-controller/
docker build -t ${DOCKER_REPO}/kubevirt/virt-controller:0.48.1-1040 .

# Virt-Handler
cd ${BASE_DIR}
cp ${OUT_DIR}/virt-chroot/virt-chroot ${DOCKER_BASE_DIR}/virt-handler/
cp ${OUT_DIR}/container-disk-v2alpha/container-disk ${DOCKER_BASE_DIR}/virt-handler/
cp ${OUT_DIR}/virt-handler/virt-handler ${DOCKER_BASE_DIR}/virt-handler/
cd ${DOCKER_BASE_DIR}/virt-handler/
docker build -t ${DOCKER_REPO}/kubevirt/virt-handler:0.48.1-1040 .


# Virt-Launcher
cd ${BASE_DIR}
cp ${OUT_DIR}/virt-launcher/virt-launcher ${DOCKER_BASE_DIR}/virt-launcher/
cp ${OUT_DIR}/container-disk-v2alpha/container-disk ${DOCKER_BASE_DIR}/virt-launcher/
cp ${CMD_DIR}/virt-freezer/virt-freezer ${DOCKER_BASE_DIR}/virt-launcher/
cp ${CMD_DIR}/virt-probe/virt-probe ${DOCKER_BASE_DIR}/virt-launcher/
cd ${DOCKER_BASE_DIR}/virt-launcher/
docker build -t ${DOCKER_REPO}/kubevirt/virt-launcher:0.48.1-1040 .

